/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package latihancitra;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
/*
* ShapePanel.java
*/
public class ShapePanel1 extends JPanel {
public ShapePanel1(){
setBackground(Color.white);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLUE);
g.fillRect(50,10,65,50);


g.setColor(new Color(255,0,0));
g.fillOval(55,50,15,20);

g.setColor(Color.BLUE);
g.fillRect(100,35,30,30);

g.setColor(new Color(255,0,0));
g.fillOval(120,50,15,20);

g.setColor(new Color(0,255,0));
g.fillArc(150,10,50,50,0,180);
Graphics2D g2 =(Graphics2D)g;
// fill RoundRectangle2D.Double
GradientPaint redtowhite = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite);
g2.fill(new RoundRectangle2D.Double(200, 10, 50,50, 10, 10));
//g2.setPaint();
g2.drawString("Filled RoundRectangle2D", 200, 80);
}
public static void main(String args[]){
JFrame frame = new JFrame( "Grafik 2 Dimensi" );
frame.addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e ){
System.exit( 0 );
}
});
frame.setLayout(new BorderLayout());
ShapePanel1 shapePanel = new ShapePanel1();
frame.add(shapePanel,BorderLayout.CENTER);
frame.setSize( 450, 250 );
frame.setVisible(true);
}
}